import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { loginStatus } from "@/stores/counter";

import App from './App.vue'
import router from './router'

const app = createApp(App)

app.use(createPinia())
app.use(router)


import { relogin } from "@/api/relogin";
relogin().finally(() => {
    const login_status = loginStatus();
    router.beforeEach((to, from, next) => {
        if (to.name !== 'login' && !login_status.isLogin) next({ name: 'login' })
        else next()
    })
})


window.apiurl = (window.location.hostname == "localhost" ? 'http://localhost:8088/' : 'http://47.94.82.79:8088/');





app.mount('#app')

